import DList from "@/components/dlist";
export default {
    data() {
      return {
        popupShow: false,
        listData:[],
        goods_name:"",
        name:"",
        explain:"",
        loading: false,
        finished: false,
        page: 1,
      }
    },
    activated() {
      this.popupShow = true;
      this.onSearch();
    },
    methods: {
      async getData() {
        if (this.loading === true || this.finished === true) {
          return;
        }
        this.loading = true;
        let {data,result,msg} = await $http.post("plugin.stock-service.frontend.controllers.home.stock",{page:this.page,goods_name:this.goods_name});
        if (result === 0) {
          this.$toast(msg);
          return;
        }
        this.explain = data.explain;
        this.name = data.name;
        this.fun.setWXTitle(data.name);
        if (data.list.data.length === 0 || data.list.data.length < data.list.per_page || data.list.current_page === data.list.last_page) {
          this.finished = true;
        }
        this.listData.push(...data.list.data);
        this.page++;
        this.loading = false;
      },
      onLoad(){
        this.getData();
      },
      onSearch() {
        this.loading = false;
        this.finished = false;
        this.page = 1;
        this.listData = [];
        this.getData();
      },
      // 跳转到详情
      goGoodsDetail(id) {
        this.$router.push(this.fun.getUrl("goods", { id }));
      }
    },
    components: { DList }
  };
  